package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Test2 {
    public static void main(String[] args) {
        UserInfo userInfo = InputUtil.getInputObject(new UserInfo(),"删除用户","删除");
        try(Connection conn = DBUtil.getConnection();) {
            String sql = "DELETE FROM userinfo WHERE username=? ";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1,userInfo.getUsername());
            //ps.setString(2,userInfo.getPassword());
            int num = ps.executeUpdate();
            System.out.println("删除" + (num > 0 ? "成功" : "失败"));


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }
}
